package edison.persistence;

import javax.jcr.Value;
import javax.jcr.nodetype.PropertyDefinition;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity(name = "PropertyDefinition")
@Table(name = "PropertyDefinition")
public class PropertyDefinitionBean {
	@Id
	private String name;
	private boolean isAutoCreated;
	private boolean isMandatory;
	private int onParentVersionAction;
	private boolean isProtected;
	@ManyToOne(targetEntity = NodeTypeBean.class)
	private String declaringNodeType;

	private int requiredType;
	private String[] valueConstraints;
	private Value[] defaultValues;
	private boolean isMultiple;
	private String[] availableQueryOperators;
	private boolean isFullTextSearchable;
	private boolean isQueryOrderable;

	public PropertyDefinitionBean() {
	}

	public PropertyDefinitionBean(PropertyDefinition pd) {
		this.name = pd.getName();
		this.isAutoCreated = pd.isAutoCreated();
		this.isMandatory = pd.isMandatory();
		this.onParentVersionAction = pd.getOnParentVersion();
		this.isProtected = pd.isProtected();
		//this.declaringNodeType = pd.getDeclaringNodeType();

		this.requiredType = pd.getRequiredType();
		this.valueConstraints = pd.getValueConstraints();
		this.defaultValues = pd.getDefaultValues();
		this.isMultiple = pd.isMultiple();
		this.availableQueryOperators = pd.getAvailableQueryOperators();
		this.isFullTextSearchable = pd.isFullTextSearchable();
		this.isQueryOrderable = pd.isQueryOrderable();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isAutoCreated() {
		return isAutoCreated;
	}

	public void setAutoCreated(boolean isAutoCreated) {
		this.isAutoCreated = isAutoCreated;
	}

	public boolean isMandatory() {
		return isMandatory;
	}

	public void setMandatory(boolean isMandatory) {
		this.isMandatory = isMandatory;
	}

	public int getOnParentVersionAction() {
		return onParentVersionAction;
	}

	public void setOnParentVersionAction(int onParentVersionAction) {
		this.onParentVersionAction = onParentVersionAction;
	}

	public boolean isProtected() {
		return isProtected;
	}

	public void setProtected(boolean isProtected) {
		this.isProtected = isProtected;
	}

	public String getDeclaringNodeType() {
		return declaringNodeType;
	}

	public void setDeclaringNodeType(String declaringNodeType) {
		this.declaringNodeType = declaringNodeType;
	}

	public int getRequiredType() {
		return requiredType;
	}

	public void setRequiredType(int requiredType) {
		this.requiredType = requiredType;
	}

	public String[] getValueConstraints() {
		return valueConstraints;
	}

	public void setValueConstraints(String[] valueConstraints) {
		this.valueConstraints = valueConstraints;
	}

	public Value[] getDefaultValues() {
		return defaultValues;
	}

	public void setDefaultValues(Value[] defaultValues) {
		this.defaultValues = defaultValues;
	}

	public boolean isMultiple() {
		return isMultiple;
	}

	public void setMultiple(boolean isMultiple) {
		this.isMultiple = isMultiple;
	}

	public String[] getAvailableQueryOperators() {
		return availableQueryOperators;
	}

	public void setAvailableQueryOperators(String[] availableQueryOperators) {
		this.availableQueryOperators = availableQueryOperators;
	}

	public boolean isFullTextSearchable() {
		return isFullTextSearchable;
	}

	public void setFullTextSearchable(boolean isFullTextSearchable) {
		this.isFullTextSearchable = isFullTextSearchable;
	}

	public boolean isQueryOrderable() {
		return isQueryOrderable;
	}

	public void setQueryOrderable(boolean isQueryOrderable) {
		this.isQueryOrderable = isQueryOrderable;
	}

}
